import { createStore } from 'vuex';

import { useService } from '@/utils/services';

import getters from './getters';
import modules from './modules';

const state = {
  currentDeptArticle: {},

  marks: []
};

const mutations = {
  setDeptArticle(state, dept) {
    state.currentDeptArticle = dept;
  },

  setMarks(state, marks) {
    state.marks = marks;
  }
};

const actions = {
  getMark({ commit }) {
    let actions = useService();
    actions.hos.getMarks().then((res) => {
      commit('setMarks', res);
    });
  }
};

export const store = createStore({
  state,
  mutations,
  actions,
  getters,
  modules: {
    ...modules
  }
});

export function setupStore(app) {
  app.use(store);
}
